package com.yxq.mdt.app.modules.socialcontact.adapter;

import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.modules.socialcontact.bean.NearbyDetailsBean;

import java.util.List;

public class NearbyDetailsAdapter extends BaseQuickAdapter<NearbyDetailsBean, BaseViewHolder> {
    public NearbyDetailsAdapter(int layoutResId, @Nullable List<NearbyDetailsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, NearbyDetailsBean item) {
        if (TextUtils.isEmpty(item.getCity())) {
            helper.setGone(R.id.nearby_city_tv, false);
        } else {
            helper.setText(R.id.nearby_city_tv, item.getCity());
        }
        if (TextUtils.isEmpty(item.getConstellation())) {
            helper.setGone(R.id.nearby_constellation_tv, false);
        } else {
            helper.setText(R.id.nearby_constellation_tv, item.getConstellation());
        }
        if (TextUtils.isEmpty(item.getBrowseLength())) {
            helper.setGone(R.id.nearby_distance_tv, false);
        } else {
            helper.setText(R.id.nearby_distance_tv, item.getBrowseLength() + "m");
        }
        if (item.getSex() == 1) {
            helper.setImageResource(R.id.nearby_nike_img, R.mipmap.xb_nan);
        } else {
            helper.setImageResource(R.id.nearby_nike_img, R.mipmap.xb_nv);
        }
        if (TextUtils.isEmpty(item.getNikeName())) {
            helper.setGone(R.id.nearby_nike_name, false);
        } else {
            helper.setText(R.id.nearby_nike_name, item.getNikeName());
        }
        helper.setText(R.id.nearby_year_tv, "" + item.getYear());
        helper.setImageResource(R.id.nearby_nike_img, item.getImgUrl());
        helper.setText(R.id.nearby_photo_tv, item.getPhoto() + "张照片");
        helper.addOnClickListener(R.id.nearby_nike_img);
        helper.addOnClickListener(R.id.nearby_attention_tv);
    }
}
